using Microsoft.EntityFrameworkCore;
using MyWebApi.Api.Entity;

namespace MyWebApi.Api.Db
{
    // 数据库上下文
    public class MyWebApiDb : DbContext
    {
        public MyWebApiDb(DbContextOptions options) : base(options)
        {

        }
        public DbSet<AuditInfo> AuditInfo { get; set; }
        public DbSet<users> users { get; set; }
        public DbSet<appraise> appraises { get; set; }
        public DbSet<attention_shop> attention_shop { get; set; }
        public DbSet<classify> classify { get; set; }
        public DbSet<commodity_picture> commodity_picture { get; set; }
        public DbSet<commodity_property> commodity_property { get; set; }
        public DbSet<commodity_property_vel> commodity_property_vel { get; set; }
        public DbSet<commodity> commodity { get; set; }
        public DbSet<order_form> order_form { get; set; }
        public DbSet<payment> payment { get; set; }
        public DbSet<personal_details> personal_details { get; set; }
        public DbSet<receiving_site> receiving_site { get; set; }
        public DbSet<shopping_cart> shopping_cart { get; set; }
        public DbSet<shopping_mall> shopping_mall { get; set; }
        public DbSet<slideshow> slideshow { get; set; }
        public DbSet<supplier> supplier { get; set; }
        public DbSet<user_role> user_role { get; set; }


        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {
            //添加种子数据
            // 用户种子数据
            modelBuilder.Entity<users>().HasData(
                // 添加管理员
                new users
                {
                    Id = 1,
                    UserName = "admin",
                    Password = "admin",
                    RoleId = 2,
                    IsDeleted = false,
                    Status = true
                },
                // 添加供货商
                new users
                {
                    Id = 2,
                    UserName = "小胖美食旗舰店",
                    Password = "111",
                    RoleId = 3,
                    IsDeleted = false,
                    Status = true
                }

            );

            // 商品种子数据
            modelBuilder.Entity<commodity>().HasData(
                // 添加管理员
                new commodity
                {
                    Id = 1,
                    commodityName = "稻花香 火鸡面网红泡面速食拉面干拌面炸酱面方便面韩式超辣6桶装",
                    Introduce = "稻花香 火鸡面网红泡面速食拉面干拌面炸酱面方便面韩式超辣6桶装",
                    surfacePlot = "https://detail.tmall.com/item.htm?id=646588464133&spm=a21bo.21814703.201876.3.53b011d9QRZEKi&scm=1007.34127.211940.0&pvid=00870ecd-a7ad-48b4-a9a3-57cf747ad6a5&sku_properties=5919063:6536025#",
                    supplierId = 1,
                    classifyId = 1,
                    IsDeleted = false,
                    Status = true
                },
                new commodity
                {
                    Id = 2,
                    commodityName = "大容量水杯女夏季网红大肚杯1000ml儿童吸管塑料杯子便携运动水壶",
                    Introduce = "大容量水杯女夏季网红大肚杯1000ml儿童吸管塑料杯子便携运动水壶",
                    surfacePlot = "https://detail.tmall.com/item.htm?id=646588464133&spm=a21bo.21814703.201876.3.53b011d9QRZEKi&scm=1007.34127.211940.0&pvid=00870ecd-a7ad-48b4-a9a3-57cf747ad6a5&sku_properties=5919063:6536025#",
                    supplierId = 1,
                    classifyId = 1,
                    IsDeleted = false,
                    Status = true
                },
                new commodity
                {
                    Id = 3,
                    commodityName = "蓝色泡泡袖短裙子法式复古设计感绑带盐系方领收腰公主仙女连衣裙",
                    Introduce = "蓝色泡泡袖短裙子法式复古设计感绑带盐系方领收腰公主仙女连衣裙",
                    surfacePlot = "https://detail.tmall.com/item.htm?id=646588464133&spm=a21bo.21814703.201876.3.53b011d9QRZEKi&scm=1007.34127.211940.0&pvid=00870ecd-a7ad-48b4-a9a3-57cf747ad6a5&sku_properties=5919063:6536025#",
                    supplierId = 1,
                    classifyId = 1,
                    IsDeleted = false,
                    Status = true
                },
                new commodity
                {
                    Id = 4,
                    commodityName = "陶瓷水果盘欧式三层点心盘蛋糕盘多层糕点盘客厅创意糖果托盘架子",
                    Introduce = "陶瓷水果盘欧式三层点心盘蛋糕盘多层糕点盘客厅创意糖果托盘架子",
                    surfacePlot = "https://detail.tmall.com/item.htm?id=646588464133&spm=a21bo.21814703.201876.3.53b011d9QRZEKi&scm=1007.34127.211940.0&pvid=00870ecd-a7ad-48b4-a9a3-57cf747ad6a5&sku_properties=5919063:6536025#",
                    supplierId = 1,
                    classifyId = 1,
                    IsDeleted = false,
                    Status = true
                },
                new commodity
                {
                    Id = 5,
                    commodityName = "火鸡面网红泡面速食拉面干拌面炸酱面方便面韩式超辣6桶装",
                    Introduce = "【现货】忠犬小八梨形自制-屋檐雨-原创不规则刺绣浅色直筒牛仔裤",
                    surfacePlot = "https://detail.tmall.com/item.htm?id=646588464133&spm=a21bo.21814703.201876.3.53b011d9QRZEKi&scm=1007.34127.211940.0&pvid=00870ecd-a7ad-48b4-a9a3-57cf747ad6a5&sku_properties=5919063:6536025#",
                    supplierId = 1,
                    classifyId = 1,
                    IsDeleted = false,
                    Status = true
                },
                new commodity
                {
                    Id = 6,
                    commodityName = "linjou玲玖赫本风小黑裙女夏季2021年新款小个子连衣裙洛丽塔裙子",
                    Introduce = "linjou玲玖赫本风小黑裙女夏季2021年新款小个子连衣裙洛丽塔裙子",
                    surfacePlot = "https://detail.tmall.com/item.htm?id=646588464133&spm=a21bo.21814703.201876.3.53b011d9QRZEKi&scm=1007.34127.211940.0&pvid=00870ecd-a7ad-48b4-a9a3-57cf747ad6a5&sku_properties=5919063:6536025#",
                    supplierId = 1,
                    classifyId = 1,
                    IsDeleted = false,
                    Status = true
                },
                new commodity
                {
                    Id = 7,
                    commodityName = "vivo TWS 2e真无线耳机新品蓝牙耳机iqoovivotws2e",
                    Introduce = "vivo TWS 2e真无线耳机新品蓝牙耳机iqoovivotws2e",
                    surfacePlot = "https://detail.tmall.com/item.htm?id=646588464133&spm=a21bo.21814703.201876.3.53b011d9QRZEKi&scm=1007.34127.211940.0&pvid=00870ecd-a7ad-48b4-a9a3-57cf747ad6a5&sku_properties=5919063:6536025#",
                    supplierId = 1,
                    classifyId = 1,
                    IsDeleted = false,
                    Status = true
                },
                new commodity
                {
                    Id = 8,
                    commodityName = "zakka木质首饰收纳盒十二格长方形分格化妆品复古桌面整理木盒子",
                    Introduce = "zakka木质首饰收纳盒十二格长方形分格化妆品复古桌面整理木盒子",
                    surfacePlot = "https://detail.tmall.com/item.htm?id=646588464133&spm=a21bo.21814703.201876.3.53b011d9QRZEKi&scm=1007.34127.211940.0&pvid=00870ecd-a7ad-48b4-a9a3-57cf747ad6a5&sku_properties=5919063:6536025#",
                    supplierId = 1,
                    classifyId = 1,
                    IsDeleted = false,
                    Status = true
                },
                new commodity
                {
                    Id = 9,
                    commodityName = "塑料厨房沥水篮晾放洗碗盘筷碟收纳架沥水碗架碗柜大号置物架用品",
                    Introduce = "塑料厨房沥水篮晾放洗碗盘筷碟收纳架沥水碗架碗柜大号置物架用品",
                    surfacePlot = "https://detail.tmall.com/item.htm?id=646588464133&spm=a21bo.21814703.201876.3.53b011d9QRZEKi&scm=1007.34127.211940.0&pvid=00870ecd-a7ad-48b4-a9a3-57cf747ad6a5&sku_properties=5919063:6536025#",
                    supplierId = 1,
                    classifyId = 1,
                    IsDeleted = false,
                    Status = true
                },
                new commodity
                {
                    Id = 10,
                    commodityName = "双耳铸铁炒锅平底电磁炉煤气灶家用炒菜锅炖锅无涂层不粘锅生铁锅",
                    Introduce = "双耳铸铁炒锅平底电磁炉煤气灶家用炒菜锅炖锅无涂层不粘锅生铁锅",
                    surfacePlot = "https://detail.tmall.com/item.htm?id=646588464133&spm=a21bo.21814703.201876.3.53b011d9QRZEKi&scm=1007.34127.211940.0&pvid=00870ecd-a7ad-48b4-a9a3-57cf747ad6a5&sku_properties=5919063:6536025#",
                    supplierId = 1,
                    classifyId = 1,
                    IsDeleted = false,
                    Status = true
                }


            );

            // 规格表种子数据
            modelBuilder.Entity<commodity_property>().HasData(
                new commodity_property
                {
                    Id = 1,
                    commodityId = 1,
                    property = "颜色",
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property
                {
                    Id = 2,
                    commodityId = 2,
                    property = "颜色",
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property
                {
                    Id = 3,
                    commodityId = 3,
                    property = "颜色",
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property
                {
                    Id = 4,
                    commodityId = 4,
                    property = "颜色",
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property
                {
                    Id = 5,
                    commodityId = 5,
                    property = "颜色",
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property
                {
                    Id = 6,
                    commodityId = 6,
                    property = "颜色",
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property
                {
                    Id = 7,
                    commodityId = 7,
                    property = "颜色",
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property
                {
                    Id = 8,
                    commodityId = 8,
                    property = "颜色",
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property
                {
                    Id = 9,
                    commodityId = 9,
                    property = "颜色",
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property
                {
                    Id = 10,
                    commodityId = 10,
                    property = "颜色",
                    IsDeleted = false,
                    Status = true
                }
            );

            modelBuilder.Entity<commodity_property_vel>().HasData(
                new commodity_property_vel
                {
                    Id = 1,
                    commodityNormsId = 1,
                    PropertyVel = "红色",
                    repertory = 333,
                    money = 20,
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property_vel
                {
                    Id = 2,
                    commodityNormsId = 2,
                    PropertyVel = "白色",
                    repertory = 112,
                    money = 30,
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property_vel
                {
                    Id = 3,
                    commodityNormsId = 3,
                    PropertyVel = "粉红色",
                    repertory = 322,
                    money = 260,
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property_vel
                {
                    Id = 4,
                    commodityNormsId = 4,
                    PropertyVel = "紫色",
                    repertory = 187,
                    money = 99,
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property_vel
                {
                    Id = 5,
                    commodityNormsId = 5,
                    PropertyVel = "红色",
                    repertory = 254,
                    money = 68,
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property_vel
                {
                    Id = 6,
                    commodityNormsId = 6,
                    PropertyVel = "天蓝色",
                    repertory = 543,
                    money = 20,
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property_vel
                {
                    Id = 7,
                    commodityNormsId = 7,
                    PropertyVel = "淡蓝色",
                    repertory = 233,
                    money = 39,
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property_vel
                {
                    Id = 8,
                    commodityNormsId = 8,
                    PropertyVel = "死亡芭比粉",
                    repertory = 3,
                    money = 999,
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property_vel
                {
                    Id = 9,
                    commodityNormsId = 9,
                    PropertyVel = "死亡金刚粉",
                    repertory = 3,
                    money = 999,
                    IsDeleted = false,
                    Status = true
                },
                new commodity_property_vel
                {
                    Id = 10,
                    commodityNormsId = 10,
                    PropertyVel = "绝版粉",
                    repertory = 1,
                    money = 99999999,
                    IsDeleted = false,
                    Status = true
                }
            );

        }



        // 连接数据库
        protected override void OnConfiguring(DbContextOptionsBuilder options)
            => options.UseSqlServer(@"server=DESKTOP-RQLSIQ5\SQLEXPRESS;database=lsxiaopangbupangtop;uid=sa;pwd=20010719;MultipleActiveResultSets=true;");
            

    }

}